package com.fujitsu.cn.fnst.service;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fujitsu.cn.fnst.base.BaseService;
import com.fujitsu.cn.fnst.dao.MeetingUseDao;
import com.fujitsu.cn.fnst.entiy.Meeting;
import com.fujitsu.cn.fnst.entiy.MeetingBook;
import com.fujitsu.cn.fnst.entiy.MeetingUse;

@Service
@Transactional
public class MeetingUseService implements BaseService<MeetingUse> {
    @Resource
    private MeetingUseDao meetingUseDao;

    @Override
    public MeetingUse find(int id) {
        return meetingUseDao.query(MeetingUse.class, id);
    }

    @Override
    public MeetingUse modify(MeetingUse t) {
        return meetingUseDao.update(t);
    }

    @Override
    public void delete(MeetingUse t) {
        meetingUseDao.delete(t);
    }

    @Override
    public MeetingUse add(MeetingUse t) {
        return meetingUseDao.insert(t);
    }

    @Override
    public List<MeetingUse> find(String queryString) {
        return meetingUseDao.query(queryString);
    }

    public MeetingUse getMeetingUse(int meetingId, Date date) {
        return meetingUseDao.getMeetingUse(meetingId, date);
    }

    public List<MeetingUse> getMeetingUses(int right, Date date) {
        return meetingUseDao.getMeetingUses(right, date);
    }

    /***
     * @return true 表示不可以使用
     * **/
    public boolean checkMeetingisVaild(Date startdate, Date endDate,
            int meetingRoom) {
        return meetingUseDao.checkMeetingisVaild(startdate, endDate,
                meetingRoom);
    }

    public void bookMeetingRoom(Date startTime, Date endTime, int meetingId) {

        meetingUseDao.bookMeetingRoom(startTime, endTime, meetingId);
    }

    public void deleteBook(MeetingBook book) {
        meetingUseDao.deleteBook(book);

    }

    public  MeetingBook meetingModel(int meetingId, String amount) {
        return meetingUseDao.meetingModel(meetingId, amount);
    }

    public List<Meeting> timeModel(String date, String beginTime,
            String endTime,
            String amount) throws ParseException {
        return meetingUseDao.timeModel(date, beginTime, endTime, amount);
    }

}
